﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var RouteCode = getQueryParam("RouteCode");
    console.log('子页面等级', RouteCode)
    $(document).ready(function () {
        // 获取 keyValue
        var keyValue = getQueryParam("keyValue");
        const rawCheckPort = getQueryParam("rawCheckPort");
        const rawDjProcedureCompany = getQueryParam("rawDjProcedureCompany");
        console.log('子页面BridgeCode', keyValue)
        console.log('子页面rawCheckPort', rawCheckPort)
        console.log('子页面rawDjProcedureCompany', rawDjProcedureCompany)
        if (keyValue) {
            $("#BridgecodeDisplay").text(keyValue);
            $("#F_CreatorTime").val(rawCheckPort);
            $("#F_StartIP").val(rawDjProcedureCompany);
        } else {
            console.error('keyValue 参数未找到！');
            $("#BridgecodeDisplay").text("参数未找到！");
        }
    });
    function getQueryParam(name) {
        const urlParams = new URLSearchParams(window.location.search);
        return urlParams.get(name);
    }
    var keyValue = getQueryParam("keyValue");
    // 提交表单处理
    function submitForm() {
        const formData = new FormData();
        const fileInput = document.getElementById('fileInput');
        console.log('fileInput', fileInput);//图片
        if (fileInput.files.length > 0) {
            formData.append("Img", fileInput.files[0]);
        } else {
            alert("请选择定检报告");
            return;
        }

        // 添加其他参数
        formData.append("bridgeCode", keyValue);
        console.log('keyValue', keyValue);
        formData.append("RouteCode", $("#F_Type").val());//桥型
        formData.append("BingHaiType", $("#F_Type").val());//病害类型
        formData.append("BingHaiDes", $("#F_CreatorUserId").val());//病害描述
        formData.append("IsImport", $("#F_TypeISimp").val());//是否重点
        formData.append("BinghaiSelect", $("#F_TypeSelect").val());//重点病害分类
        formData.append("Score", $("#F_CreatorScore").val());//重点病害分类
        $.ajax({
            url: "/SystemSecurity/BridgeMange/UpdateDiseaseData11",
            type: "POST",
            data: formData,
            processData: false,
            contentType: false,
            success: function (res) {
                alert("上传成功");
                parent.layer.close(parent.layer.getFrameIndex(window.name));
                parent.layer.closeAll();
            }
        });
    }
    var keyValue = $.request("keyValue");
    $(function () {
        $("#F_Type").bindSelect()
        $.ajax({
            url: "/SystemSecurity/FilterIP/GetFormJson",
            data: { keyValue: keyValue },
            dataType: "json",
            async: false,
            type: "GET",
            success: function (data) {
                $("#form1").formSerialize(data);
            }
        });
    });

</script>

<form id="form1">
    <div style="margin-bottom: 0px; border-radius: 0px;" class="alert alert-warning alert-dismissable">
        <strong>注意：</strong>&nbsp;请准确输入定检承担单位等字段
    </div>
    <div style="padding-top: 20px; margin-right: 20px;">
        <div class="gridPanel">
            <table id="gridList"></table>
        </div>
        <table class="form">
            <tr>
                <th class="formTitle">桥梁代码</th>
                <td class="formValue">
                    <span id="BridgecodeDisplay"></span>
                    <!-- 或使用 <input type="text" id="BridgecodeDisplay" readonly class="form-control"> -->
                </td>
            </tr>
            <tr>
                <th class="formTitle">桥型</th>
                <td class="formValue">
                    <select id="F_Type" name="F_Type" class="form-control">
                        <option value="">==请选择==</option>
                        <option value="梁式桥">梁式桥</option>
                        <option value="板拱桥">板拱桥</option>
                        <option value="斜拉桥">斜拉桥</option>
                        <option value="悬索桥">悬索桥</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="formTitle">病害类型</th>
                <td class="formValue">
                    <select id="F_Type" name="F_Type" class="form-control">
                        <option value="">==请选择==</option>
                        <option value="level1">表现病害</option>
                        <option value="level2">水平位移</option>
                        <option value="level3">锚坑漏水</option>
                        <option value="level4">锚顶扭转</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">选项</th>
                <td class="formValue" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="F_EnabledMark" name="F_EnabledMark" type="checkbox" checked="checked"><label for="F_EnabledMark">有效</label>
                    </div>
                </td>
            </tr>
            <tr>
                <th class="formTitle">病害图片上传</th>
                <td>
                    <input type="file" name="file" id="fileInput">
                </td>
            </tr>
            <tr>
                <th class="formTitle">分数</th>
                <td class="formValue">
                    <input id="F_CreatorScore" name="F_CreatorScore" type="text" class="form-control" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">病害描述</th>
                <td class="formValue">
                    <input id="F_CreatorUserId" name="F_CreatorUserId" type="text" class="form-control" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">是否重点病害</th>
                <td class="formValue">
                    <select id="F_TypeISimp" name="F_TypeISimp" class="form-control">
                        <option value="">==请选择==</option>
                        <option value="是">是</option>
                        <option value="否">否</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="formTitle">重点病害分类</th>
                <td class="formValue">
                    <select id="F_TypeSelect" name="F_TypeSelect" class="form-control">
                        <option value="">==请选择==</option>
                        <option value="厢梁腹板竖向裂缝">厢梁腹板竖向裂缝</option>
                        <option value="梁腹板竖向裂缝">T梁腹板竖向裂缝</option>
                    </select>
                </td>
            </tr>
        </table>
        <div style="margin-top: 30px; text-align: center; border-top: 1px solid #eee; padding-top: 20px;">
            <button type="submit"
                    class="btn btn-primary btn-lg"
                    style="min-width: 150px;"
                    onclick="return submitForm()">
                <i class="fa fa-save"></i> 提交
            </button>
        </div>
    </div>
</form>
